package com.stark.commons.spring.web.boot.properties;

import java.util.ArrayList;
import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.RequestMethod;

import lombok.Data;

/**
 * zuul 网关接口级别超时配置。
 * @author Ben
 * @since 1.0.0
 * @version 1.0.0
 */
@ConfigurationProperties("zuul")
@Data
public class ZuulTimeoutProperties {
	
	/** 各微服务超时配置 */
	private List<RouteTimeout> routeTimeout = new ArrayList<>();
	
	@Data
	public static class RouteTimeout {
		
		/** 微服务 ID */
		private String serviceId;
		
		/** URI 超时配置 */
		private List<UriTimeout> uriTimeout = new ArrayList<>();
		
	}
	
	@Data
	public static class UriTimeout {
		
		/** URI */
		private String uri;
		
		/** 请求方法，默认 get */
		private RequestMethod method = RequestMethod.GET;

		/** 连接超时毫秒数，默认 1000 */
		private int connectTimeout = 1000;
		
		/** 读取数据超时毫秒数，默认 1000 */
		private int readTimeout =  1000;
		
	}
	
}
